package util.BReceiverUtil;

import android.content.Context;

import org.apache.log4j.*;

import cn.jpush.android.api.JPushMessage;
import cn.jpush.android.service.JPushMessageReceiver;
import data.SharedPreferencesUtils;
import util.HomeUtil;
import util.LogUtil;

/**
 * 自定义JPush message 接收器,包括操作tag/alias的结果返回(仅仅包含tag/alias新接口部分)
 * */
public class MyJPushMessageReceiver extends JPushMessageReceiver {
    private org.apache.log4j.Logger mLogger = org.apache.log4j.Logger.getLogger(HomeUtil.class);
    @Override
    public void onTagOperatorResult(Context context,JPushMessage jPushMessage) {
        //TagAliasOperatorHelper.getInstance().onTagOperatorResult(context,jPushMessage);
        LogUtil.eE("","..................onTagOperatorResult.......sequence..."+jPushMessage.getSequence());
        LogUtil.eE("","..................onTagOperatorResult.......getTags().size()..."+jPushMessage.getTags().size());
        LogUtil.eE("","..................onTagOperatorResult.......jPushMessage.getErrorCode()..."+jPushMessage.getErrorCode());
        if(jPushMessage.getErrorCode() == 0){
            mLogger.info(".......setPushAurora......设置极光的tags.....成功");
            if(jPushMessage.getTags().size() == 2){
                SharedPreferencesUtils.setParam(context, HomeUtil.AppAltairPushIden_Statr,true);
            }
        }else {
            mLogger.info(".......setPushAurora......设置极光的tags.....失败..Code.."+jPushMessage.getErrorCode());
        }
        super.onTagOperatorResult(context,jPushMessage);
    }
    @Override
    public void onCheckTagOperatorResult(Context context,JPushMessage jPushMessage){
       // TagAliasOperatorHelper.getInstance().onCheckTagOperatorResult(context,jPushMessage);
        LogUtil.eE("","..................onCheckTagOperatorResult.......sequence..."+jPushMessage.getSequence());
        LogUtil.eE("","..................onCheckTagOperatorResult.......getTags().size()..."+jPushMessage.getTags().size());
        LogUtil.eE("","..................onCheckTagOperatorResult.......jPushMessage.getErrorCode()..."+jPushMessage.getErrorCode());
        super.onCheckTagOperatorResult(context,jPushMessage);
    }
    @Override
    public void onAliasOperatorResult(Context context, JPushMessage jPushMessage) {
        //TagAliasOperatorHelper.getInstance().onAliasOperatorResult(context,jPushMessage);
        LogUtil.eE("","..................onAliasOperatorResult.......sequence..."+jPushMessage.getSequence());
        LogUtil.eE("","..................onAliasOperatorResult.......getTags().size()..."+jPushMessage.getTags().size());
        LogUtil.eE("","..................onAliasOperatorResult.......jPushMessage.getErrorCode()..."+jPushMessage.getErrorCode());
        super.onAliasOperatorResult(context,jPushMessage);
    }
}
